Repository navigation
Conversation
…es from the origin the file defines, as failing regression tests for issue #86 covering origin choice 2, listed operations at arbitrary origins, and a warning for an ambiguous origin Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@stevengeorge128, @Akadib, I worked with Claude to create these tests for non-standard space-group origins. I don't mind who fixes this, or if you both work on it. The plus is that you will learn some crystallography. Please read the comment and see if you can understand what is going on and craft a solution. When all the tests turn green and this is merged, this will close #86 which is on our current release path. This fixes a long-standing problem with our @Tieqiong, @sbanerjee23 I am tagging you both. This will make you both v. happy. |
|
btw, I didn't c;heck Claude's tests, so we may want to have a crystallographer (@sbanerjee23, @cadenmyers13 ?) check them for correctness..... Don't let that hold up the fix work though. Let's work on that in parallel. |
Adds
tests/test_cif_origin.py, a set of regression tests for how the CIF parserchooses the unit cell origin when it expands a structure. Relates to #86, #183,
diffpy/diffpy.pdfgui#291 and diffpy/diffpy.srfit#213.
This PR is expected to be red. It contains tests only. The fix will be
developed in a PR against this branch (
cif-origin-tests), and this branch ismerged into
mainonce the tests are green. Please do not merge it before then.main, 166 pass as guards.closes #86 once the fix has been merged into this branch.
🤖 Generated with Claude Code
Background: what these tests describe
A CIF file defines its symmetry, and therefore where the cell origin sits, in one
of these ways, from most to least explicit:
_space_group_symop_operation_xyzor_symmetry_equiv_pos_as_xyz),_space_group_name_Hall),F d -3 m :2, orICSD style
F d -3 m Z/F d -3 m S),What the parser does today
tabulated in
diffpy.structure.spacegroups. If they do not match and the filealso has an IT number or a recognizable H-M symbol, the listed operations are
silently dropped and the tabulated default is used.
The result is the symptom in #86 and diffpy/diffpy.pdfgui#291: atoms generated
with the wrong operations, so sites are duplicated or sit too close together.
The cases
:2symbol:2,:1,Z,S)The 24 two-origin groups are 48, 50, 59, 68, 70, 85, 86, 88, 125, 126, 129, 130,
133, 134, 137, 138, 141, 142, 201, 203, 222, 224, 227, 228.
Two points that are easy to get wrong:
along the polar direction, but that slide does not change the symmetry
operations, so these files already expand correctly. Those tests pass and must
keep passing.
axis is moved to x = 1/4, perpendicular to the axis. That is an arbitrary,
non-conventional origin. Any group except P1 can be written that way, and the
file is valid as long as it lists its operations.
The behaviour we want
If the file lists its symmetry operations, the structure is expanded with
those operations, whatever origin they describe.
Without listed operations, a Hall symbol or an origin qualifier on the H-M
symbol (
:1,:2,S,Z, with or without spaces) decides the origin, evenwhen an IT number is also present.
If the group has two origins and nothing in the file says which one is used,
use origin choice 1 and emit exactly one
UserWarningwith this text:The text is the constant
AMBIGUOUS_ORIGIN_WARNINGat the top of the test file.No such warning when the origin is unambiguous.
The tests
Each test builds a small CIF in memory and compares the parsed structure with
the sites generated by the operations that the file defines.
test_origin_choice_2:2,:2only, number + Hall)test_origin_choice_spellingtest_ambiguous_origin_warningtest_unambiguous_origin_no_warningtest_pyrochlore_origin_choice_2[16, 16, 48, 8], not[8, 8, 96, 32]test_listed_symops_arbitrary_origintest_listed_symops_handwrittentest_floating_origintest_two_origin_tableTotal: 574 cases, 408 failing and 166 passing. The origin-choice-2 shifts and
Hall symbols in the test file were checked against an independent space group
library (gemmi), which is not a dependency of the tests.
The tests are the specification. Please do not change the expected values to
make them pass; if you think a test is wrong, say so in the PR and we will
discuss it.
One case is deliberately not covered because it has no single right answer
beyond the warning above: a plain symbol such as
F d -3 mwith origin choice 2coordinates and no operations. A related problem that is also out of scope here:
for the seven rhombohedral groups,
R -3 mby name resolves to rhombohedralaxes while number 166 resolves to hexagonal axes.
How to work on this (forking workflow)
The fix goes on a branch of your fork that starts from
cif-origin-tests, andyour PR targets
cif-origin-tests, notmain.# In your clone of your fork. Skip the first line if "upstream" already exists. git remote add upstream https://github.com/diffpy/diffpy.structure.git git fetch upstream git checkout -b cif-origin-fix upstream/cif-origin-tests git push -u origin cif-origin-fixRun the tests: